//
//  XHBasicViewController.m
//  xinhua_sx
//
//  Created by 党阳阳 on 14-5-23.
//  Copyright (c) 2014年 broadwave.com. All rights reserved.
//

#import "XHBasicViewController.h"
#import "XHMainViewControllerDelegate.h"
#import <QuartzCore/QuartzCore.h>



@interface XHBasicViewController ()

@end

@implementation XHBasicViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
       
        self.view.frame = [[UIScreen mainScreen] bounds];
        CGFloat aY = kIOS_VERSION<7.0?0:20;
        
        _navBar = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 44.0+aY)];
              _navBar.backgroundColor = [UIColor colorWithRed:2.0/255 green:102.0/255 blue:172.0/255 alpha:1.0];
        _navBar.userInteractionEnabled = YES;
//        _navBar.layer.shadowColor = [[UIColor blackColor]CGColor];
//        _navBar.layer.opacity = 0.6f;
//        _navBar.layer.shadowOffset = CGSizeMake(3, 5);
        
        _titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, aY, self.view.frame.size.width, 44)];
        _titleLable.backgroundColor = [UIColor clearColor];
       
        _titleLable.textColor = [UIColor whiteColor];
        _titleLable.font = [UIFont systemFontOfSize:20];
        _titleLable.textAlignment = NSTextAlignmentCenter;
        [_navBar addSubview:_titleLable];
        
        
        @weakify(self);
        _leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, aY, 40,40.0)];
        [_leftButton setImage:[UIImage imageNamed:@"showLeft.png"] forState:UIControlStateNormal];
        _leftButton.imageEdgeInsets = UIEdgeInsetsMake(10, 13, 5, 5)
        ;        [[_leftButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
            @strongify(self);
            [self.delegate showLeftView];
        }];
        
        _rightButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-40, 5+aY, 40, 40)];
        [_rightButton setImage:[UIImage imageNamed:@"weather_rain_medium.png"] forState:UIControlStateNormal];
        [[_rightButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
            @strongify(self);
            [self.delegate showRightView];
        }];
        
        
        
        [_navBar addSubview:_rightButton];
        [_navBar addSubview:_leftButton];
        [self.view addSubview:_navBar];
        self.view.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
